package org.example.leetCode;

/**
 * @author Vader
 * @date 2021/11/5
 **/
public class NumSub {
    public static void main(String[] args) {
        System.out.println(numSub("0110111"));
    }

    public static int numSub(String s) {
        char[] chars = s.toCharArray();
        int result = 0;
        int size = 0;
        for (char c : chars) {
            if (c == '1') {
                size += 1;
            } else {
                result += squre(size);
                size = 0;
            }
        }

        return (result + squre(size)) % 1000000007;
    }

    private static int squre(int size) {
        if (size==1){
            return 1;
        }else if (size==0){
            return 0;
        }
        return size + squre(size - 1);
    }
}
